from asyncio import gather

import pytest
import os
from common.Yaml import Yaml
from common.Request import Request
from common.Path import project_path
import allure
filepath=project_path()
#读取common.yaml文件,headers,base_url等信息
common_yaml_file=os.path.join(filepath,"common", "common.yaml")
common_yaml_data = Yaml(common_yaml_file).read_yaml()
headers=common_yaml_data['headers']
base_url=common_yaml_data['base_url']
#读取供应商新增yaml文件
supplier_add_yaml_file=os.path.join(filepath,"api", "procurement","supplier", "addSupplier.yaml")
supplier_add_yaml_data = Yaml(supplier_add_yaml_file).read_yaml()
supplier_add_data=supplier_add_yaml_data['test_cases'][0]


print(supplier_add_yaml_data)
print(supplier_add_data)


#实例化域名
req=Request(base_url)


#新增供应商

def supplier_add(supplierName,supplierCode):

        json_dict = supplier_add_data['data']
        json_dict['supplierName'] = supplierName
        json_dict['supplierCode'] = supplierCode
        response=req.send_request(method=supplier_add_data['method'],url=base_url+supplier_add_data['url'],json=json_dict,headers=headers).json()
        return response

    #print(f"正在执行测试: {title}")



'''
supplier_counter = 0
for i in range(10000):

    supplier_counter += 1
    supplierName = f"供应商0528新增{supplier_counter}"
    supplierCode = f"G20250528{supplier_counter:05d}"  # 确保 supplierCode 是5位数
    response = supplier_add(supplierName, supplierCode)
    print(f"响应: {response}")
    '''




